package de.baumann.browser.present

import de.baumann.browser.api.OdinObserver
import de.baumann.browser.api.net.vo.Steal
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.IStealView
import de.baumann.browser.model.MiningModel
import de.baumann.browser.rx.RxSchedulers
import de.baumann.browser.utils.isLogined

class StealPresenter : BasePresenter<IStealView>() {
    private val miningModel = MiningModel()

    fun getCanStealList() {
        if (!isLogined()) {
            return
        }

        miningModel.canStealList
                .subscribe(object : OdinObserver<List<Steal>>(view) {
                    override fun onSuccess(data: List<Steal>) {
                        if (view != null) {
                            view.setStealData(data)
                        }
                    }
                })
    }

    fun getOftenStealList() {
        if (!isLogined()) {
            return
        }

        this.miningModel.oftenStealList
                .subscribe(object : OdinObserver<List<Steal>>() {
                    override fun onSuccess(data: List<Steal>?) {
                        if (view != null && data != null) {
                            view.setStealData(data)
                        }
                    }
                })
    }

}